#文件相关操作代码示例

directory="D:\\PyProjects\\PythonCourse\\3_Function\\File_operation\\Poem_Mao.txt"
#读取整个文件
file=open(directory,"r",encoding='utf-8')
content=file.read()
print("content=\n",content)
file.close()

#读取一行
file=open(directory,"r",encoding='utf-8')
line=file.readline()
print("line=\n",line)
file.close()

#读取多行
file=open(directory,"r",encoding='utf-8')
lines=file.readlines()
print("lines=\n",lines)
file.close()


#可迭代对象

#for line in file:
#    print(line)
#    readline=file.readline()
#   print(readline)